<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise.any()</title>
</head>

<body>
    <script>
        const f1 = new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve('first');
            }, 3000)
        });

        const f2 = new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve('second');
            }, 2000)
        });

        const f3 = new Promise((resolve, reject) => {
            setTimeout(() => {
                reject('third err');
            }, 500)
        });

        const f4 = Promise.reject('err');

        const f5 = new Promise((resolve, reject) => {
            setTimeout(() => {
                reject('five err');
            }, 100)
        });

        Promise.any([f1, f2, f3, f4, f5]).then(res => {
            console.log(res); //  second   获得resove用时最短得结果不会受reject影响
        });
    </script>
</body>

</html>